let form = document.querySelector('form');
let arr = [true,true]
let tip = document.querySelector('.tips');
let persons = [
    { "username":"12345678901","password":"111111" },
    { "username":"22345678901","password":"222222" },
    { "username":"32345678901","password":"333333" },
]
// var reg = /^1\d{10}$/;
let phoneReg = /^1\d{10}$/;
form.tel.onblur = function () {
    if (phoneReg.exec(this.value)) {
        tip.style.display = "none";
        arr[0] = true;
    } else {
        tip.style.display = "block";
        arr[0] = false;
    }
}

//2.判断密码格式
// var reg1 = /^\w{6}$/;
let pswReg = /^\w{6,10}$/;
form.pass.onblur = function () {
    if (pswReg.test(this.value)) {
        tip.style.display = "none";
        arr[1] = true;
    } else {
        tip.style.display = "block";
        arr[1] = false;
    }
}

let loginbtn = form.querySelector('.loginbtn');
loginbtn.onclick = () => {
    form.tel.focus();
    form.tel.blur();
    form.pass.focus();
    form.pass.blur();
    if(persons.some(i=>i.username === form.tel.value &&i.password===form.pass.value)){
        alert("登陆成功");
    }else{
        alert("登陆失败");
    }
    return false;
}